package com.springboot.learn;

import com.springboot.learn.bean.Person;
import com.springboot.learn.config.MainConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *describe:主测试类
 *
 *@author zhanghaixuan
 *@date 2018/12/25
 **/
public class MainTest {

	public static void main(String[] args) {
		/**
		 * 使用 xml 方式来 注入 bean  以前的用法
		 */
//		ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("bean.xml");
//		Person person =(Person) classPathXmlApplicationContext.getBean("person");
//		System.out.println(person);

		AnnotationConfigApplicationContext annotation = new AnnotationConfigApplicationContext(
				MainConfig.class);


		Person bean = annotation.getBean(Person.class);
		System.out.println(bean);


		String[] beanNamesForType = annotation.getBeanNamesForType(Person.class);
		for(String name : beanNamesForType) {
			System.out.println(name);
		}
	}
}
